home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992…tember: A ROM With a View / devSep92 / devSep92.dmg / Periodicals / develop / develop 11 code / Graphical Truffles / DirectPlotColorIcon.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-15  |  2.7 KB  |  72 lines  |  [TEXT/MPS ]

  1. #include "DirectScreen.h"
  2.  
  3. void DirectPlotColorIcon(long *colorIconPtr, PixMapHandle screenPixMap, short row, short col)
  4. /*
  5.     Draws a color icon image directly to the pixMap passed.
  6.     colorIconPtr = pointer to the image data for a color icon
  7.     screenPixMap = handle to the pixMap for the screen we're writing on
  8.     row, col      = location of the top left corner of the icon in the 
  9.                     pixMap's coordinate system; 
  10.                     since we know the icon is 32 by 32, 
  11.                     the other coordinates are unnecessary.
  12. */
  13. {
  14.     register long *screenMemPtr;        // Pointer to video memory
  15.     register short numRowsToCopy;        // Rows we are going to copy
  16.     register short stripRowBytes;        // To clear high bit of rowbytes
  17.     register short rowLongsOffset;        // rowBytes converted to long
  18.              char  mmuMode;                // 32-bit mode required
  19.              Rect  cursRect;            // rectangle for shield cursor call
  20.              Point cursOffset;            // 0,0 to indicate rect is in global coordinates
  21.              
  22.     /* High bit of pixMap rowBytes must be cleared. */
  23.     stripRowBytes = (0x7FFF & (**screenPixMap).rowBytes);
  24.  
  25.     /* We must strip the high byte of the address of the color icon, which, if we're in
  26.         24-bit mode, may be garbage when we go to 32-bit mode to access video memory. */
  27.     colorIconPtr = (long *)StripAddress(colorIconPtr);
  28.     
  29.     /* Calculate the address of the first byte of the destination. */
  30.     screenMemPtr = (long *)(GetPixBaseAddr(screenPixMap) + (stripRowBytes * row) + col);
  31.  
  32.     /* call shield cursor to maintain compatibility with all displays */
  33.     /* This rectangle should be a parameter, but this was added to late */
  34.     cursOffset.h = 0;
  35.     cursOffset.v = 0;
  36.     cursRect.top = row;
  37.     cursRect.left = col;
  38.     cursRect.bottom = row + 32;
  39.     cursRect.right = col + 32;
  40.     ShieldCursor(&cursRect,cursOffset);
  41.     
  42.     /* Change to 32-bit addressing mode to access video memory. The previous addressing mode 
  43.         is returned in mmuMode for restoring later. */
  44.     mmuMode = true32b;
  45.     SwapMMUMode(&mmuMode);
  46.     
  47.     numRowsToCopy = 32;                        /* Color icons have 32 rows. */
  48.     
  49.     /* Calculate the long word offset from the end of one row of the color icon on the screen's 
  50.         pixMap to the first byte of the icon in the next row. */
  51.     rowLongsOffset = (stripRowBytes/4) - 8;
  52.     
  53.     /* Draw the color icon directly to the screen. */
  54.     do {
  55.             *screenMemPtr++ = *colorIconPtr++;
  56.             *screenMemPtr++ = *colorIconPtr++;
  57.             *screenMemPtr++ = *colorIconPtr++;
  58.             *screenMemPtr++ = *colorIconPtr++;
  59.             *screenMemPtr++ = *colorIconPtr++;
  60.             *screenMemPtr++ = *colorIconPtr++;
  61.             *screenMemPtr++ = *colorIconPtr++;
  62.             *screenMemPtr++ = *colorIconPtr++;
  63.     
  64.         /* Bump to start of next row. */
  65.             screenMemPtr += rowLongsOffset;
  66.     } while(--numRowsToCopy);
  67.     
  68.     
  69.     SwapMMUMode(&mmuMode);        /* Restore addressing mode back to what it was. */
  70.     ShowCursor();
  71. }
  72.